package com.nn.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.nn.mapper.RightsMapper;
import com.nn.pojo.Rights;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RightsServiceImpl implements RightsService {
    @Autowired
    private RightsMapper rightsMapper;

    @Override
    public List<Rights> getThreeRightsIds(Integer roleId) {
        return null;
    }

    @Override
    public List<Rights> getRightsListAll() {
        return null;
    }

    @Override
    public List<Rights> getRightsList() {
        QueryWrapper<Rights> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parent_id", 0);
        List<Rights> oneList = rightsMapper.selectList(queryWrapper);
        for (Rights oneRights : oneList) {
            queryWrapper.clear();
            queryWrapper.eq("parent_id", oneRights.getId());
            List<Rights> children = rightsMapper.selectList(queryWrapper);
            oneRights.setChildren(children);
        }
        return oneList;
    }
}
